using System.IO;
using UnityEditor;
using UnityEngine;

public static class LayerMaskGenerator {
#if UNITY_EDITOR

	[MenuItem("Tools/Generate Layer Mask Layer Values")]
	public static void GenerateLayerMaskLayerValues() {
		string filePath = Application.dataPath + "/Scripts/Utils/LayerMaskLayers.cs";
		using ( StreamWriter writer = new StreamWriter(filePath) ) {
			writer.WriteLine("using UnityEngine;");
			writer.WriteLine();
			writer.WriteLine("public static class LayerMaskLayers {");
			for ( int i = 0; i < 32; i++ ) {
				string layerName = LayerMask.LayerToName(i);
				if ( !string.IsNullOrEmpty(layerName) ) {
					writer.WriteLine("\tpublic const int " + layerName.Replace(" ", "") + " = " + (1 << i) + ";");
				}
			}
			writer.WriteLine("}");
		}
		AssetDatabase.Refresh();
	}

#endif
}
